package org.cycuchy.hp.components.player {
	
	import flash.events.MouseEvent;
	
	import mx.containers.Canvas;
	
	import org.cycuchy.hp.data.EmPeCzyData;
	import org.cycuchy.hp.data.EmPeCzysData;

	public class HPPlayer_code extends Canvas {
		
		public var mp3:MP3Player;
		public var marquee:HPMarquee; 

		private var _empeczys:EmPeCzysData;
		
		private var curr:int;
		
		public function HPPlayer_code()	{
			super();
			curr = 0;
		}
		
		public function set empeczys(value:EmPeCzysData):void {
			_empeczys = value;
		}
		
		public function play(event:MouseEvent):void {
//			trace(curr);
			var empeczy:EmPeCzyData = EmPeCzyData(_empeczys.empeczys.getItemAt(curr));
			//trace(empeczy.empeczyName, " ", empeczy.empeczyUrl);
			mp3.stop()
			mp3.url = empeczy.empeczyUrl;
			mp3.play();
			marquee.marqueeText = empeczy.empeczyName;
			marquee.play();
		}
		
		public function prev(event:MouseEvent):void {
			curr--;
			if (curr < 0) {
				curr = _empeczys.empeczys.length - 1;
			}
			play(event);
		}
		
		public function next(event:MouseEvent):void {
			curr++;
			if (curr > _empeczys.empeczys.length - 1) {
				curr = 0;
			}
			play(event);
		}
		
		public function stop(event:MouseEvent):void {
			//trace("HPPlayer_code:stop");
			marquee.stop();
			mp3.stop();
		}
		
	}
	
}